// 中间件函数
function validateField(key, method = "get") {

    return function (req, res, next) {
        let data = method == "get" ? req.query : req.body;

        if (Object.hasOwn(data, key)) {  // 存在此字段
            next();
        } else {
            res.send({
                code: 100,
                message: "请传入完整参数:" + key,
            })
        }
    }

}



module.exports = {
    validateField,
}